<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>添加用户</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui/css/layui.css">
    <link rel="stylesheet" href="../css/scroll-bar.css">
    <link rel="stylesheet" href="../css/sub-page.css">
    <link rel="stylesheet" href="../css/font.css">
</head>

<body>
    <div class="ok-body">
        <!--面包屑导航区域-->
        <div class="ok-body-breadcrumb">
            <span class="layui-breadcrumb">
                <a><cite>首页</cite></a>
                <a><cite>任务管理</cite></a>
                <a><cite>新建任务</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" href="javascript:location.replace(location.href);" title="刷新">
                <i class="layui-icon layui-icon-refresh"></i>
            </a>
        </div>

        <!--工具栏-->
       <!--  <okToolbar>
              <button class="layui-btn layui-btn-normal" id="batchEnabled">
            <i class="iconfont icon-shangsheng"></i>批量启用
        </button>
        <button class="layui-btn layui-btn-warm" id="batchDisabled">
            <i class="iconfont icon-web-icon-"></i>批量停用
        </button>
        <button class="layui-btn layui-btn-danger" id="batchDel">
            <i class="layui-icon layui-icon-delete"></i>批量删除
        </button>
            <button class="layui-btn" id="addUser">
                <i class="layui-icon">&#xe61f;</i>保存任务
            </button>
        </okToolbar> -->
        <div class="layui-tab">
            <ul class="layui-tab-title">
                <li class="layui-this">基础设置</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <!--form表单-->
                    <form class="layui-form layui-form-pane">
                        <div class="layui-form-item">
                            <label class="layui-form-label">数据集名称</label>
                            <div class="layui-input-block">
                                <input type="text" name="dsname" placeholder="请输入数据集名称" autocomplete="off" class="layui-input"
                                    lay-verify="required">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">数据集标签</label>
                            <div class="layui-input-block">
                                <input type="text" name="dstags" placeholder="请输入数据集标签" autocomplete="off" class="layui-input"
                                    lay-verify="required">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">数据集描述</label>
                            <div class="layui-input-block">
                                <textarea placeholder="请输入数据集描述" class="layui-textarea" name="description"></textarea>
                            </div>
                        </div>

                        <!-- <div class="layui-inline">
                            <label class="layui-form-label">标注分类</label>
                            <div class="layui-input-inline">
                                <select name="modules" lay-verify="required" lay-search="">
                                    <option value="">直接选择或搜索选择</option>
                                    <option value="1">数据清洗</option>
                                    <option value="2">资源分类</option>
                                    <option value="3">多点标注</option>
                                </select>
                            </div>
                        </div> -->
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="add">立即提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!--js逻辑-->
    <script src="../lib/layui/layui.js"></script>

    <script>
        layui.use(['element', 'form', 'jquery'], function () {
            var form = layui.form;
            var $ = layui.jquery;
            form.on('submit(add)', function (data) {
                console.log(data.field);
                $.ajax({
                    url: '/dataset/add',
                    method: 'post',
                    data: data.field,
                    dataType: 'JSON',
                    success: function (res) {
                        if (res.code == 1) {
                            layer.msg('操作成功');
                            parent.layer.close(parent.layer.getFrameIndex(window.name));
                        } else {
                            layer.msg('操作失败');
                        }
                    },
                    error: function (data) {}
                })

                return false;
            });
        })
    </script>
</body>

</html>